package cn.chia.utils;

import java.util.Date;
import java.util.UUID;

import org.apache.struts2.ServletActionContext;

import cn.chia.pojo.User;


public class UUIDUtil {
	//生成订单号
	//订单号由用户id的后两位，毫秒时间的中间8位，再加上随机1~100中的两位数生成
	public static String getUUID(){
		User user = (User) ServletActionContext.getRequest().getSession().getAttribute("user");
		String id = user.getUserid()+"";
		String d = new Date().getTime()+"";
		String rd = (int)Math.ceil(Math.random()*100)+"";
		String str = id.substring(3)+d.substring(3, 11)+rd;
		
		return str;
	}
	
	public static String getPicName(){
		UUID uuid = UUID.randomUUID();
		String str = uuid.toString().replaceAll("-", "");
		
		return str;
	}
}
